package com;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import com.ebay.gcn.appcenter.webservice.SubscriptionInformationWebService;
import com.ebay.gcn.appcenter.webservice.ValidateSubscription;
import com.ebay.gcn.appcenter.webservice.ValidateSubscriptionResponse;
import com.test.services.seller.subscriptioninformationservicemessages.ErrorType;
import com.test.services.seller.subscriptioninformationservicemessages.GetSubscriptionPlansRequestType;
import com.test.services.seller.subscriptioninformationservicemessages.GetSubscriptionPlansResponseType;
import com.test.services.seller.subscriptioninformationservicemessages.SubscriptionPlanListType;
import com.test.services.seller.subscriptioninformationservicemessages.SubscriptionPlanType;
import com.test.services.seller.subscriptioninformationservicemessages.ValidateSubscriptionRequestType;
import com.test.services.seller.subscriptioninformationservicemessages.ValidateSubscriptionResponseType;




public class SubscriptionPlanTestClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		URL url;
		try {
//			url = new URL(
//					"http://localhost:8080/webservice/SubscriptionInformationWebService?wsdl");
			url = new URL(
					"http://10.221.1.7:8080/appcenter/webServices/SubscriptionInformationWebService?wsdl");
			// 1st argument service URI, refer to wsdl document above
			// 2nd argument is service name, refer to wsdl document above
			QName qname = new QName("http://webservice.appcenter.gcn.ebay.com/",
					"SubscriptionInformationWebService");

			Service service = Service.create(url, qname);

			SubscriptionInformationWebService testService = service
					.getPort(SubscriptionInformationWebService.class);

			GetSubscriptionPlansRequestType requestType = new GetSubscriptionPlansRequestType();
			System.out.println("-------------requestType------");
			requestType.setACAppKey("e8785fef-9aee-40ff-b7f9-656f9d85026e");
			requestType.setACDevKey("91a8f167-1494-4176-b5d7-3a10d666c667");
			requestType.setAppUUID("1.0");

			GetSubscriptionPlansResponseType responseType = testService
					.getSubscriptionPlans(requestType);
			ErrorType error = responseType.getError();
			System.out.println(error.getCode());
			System.out.println(error.getMessage());
			SubscriptionPlanListType subscriptionPlanListType=responseType.getSubscriptionPlanList();
			List<SubscriptionPlanType> planTypes = subscriptionPlanListType
					.getSubscriptionPlan();
			System.out.println(planTypes);
			for (SubscriptionPlanType planType : planTypes) {
				System.out.println("Plan:");
				System.out.print(planType.getSubscriptionPlanDetail()+"  ");
				System.out.print(planType.getSubscriptionPlanID()+"  ");
				System.out.println(planType.getSubscriptionPlanFee()+"  ");
			}
			/*
			ValidateSubscriptionRequestType requestType = new ValidateSubscriptionRequestType();
			requestType.setACAppKey("e8785fef-9aee-40ff-b7f9-656f9d85026e");
			requestType.setACDevKey("91a8f167-1494-4176-b5d7-3a10d666c667");
			requestType.setAppUUID("8.0");
			requestType.setEBayEAISTokenID("nY+sHZ2PrBmdj6wVnY+sEZ2PrA2dj6wFk4GhCpSFowqdj6x9nY+seQ==");
			ValidateSubscriptionResponseType responseType = testService.validateSubscription(requestType);
//			
			ErrorType error = responseType.getError();
			System.out.println(error.getCode());
			System.out.println(error.getMessage());
			System.out.println(responseType.getSubscriptionStatus().value());*/
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
